/* GUI CONVERTED from ececmtb.p (converter v1.76) Mon May 12 22:54:35 2003 */
/* ececmtb.p - SCROLLING DOCUMENT SELECTION MENU (PCO/PCR)                    */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.8.1.11 $                                                      */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.4      LAST MODIFIED: 07/12/93   BY: pma *H013*                */
/* REVISION: 7.4      LAST EDIT: 10/27/94   MODIFIED BY: ame *H578*           */
/* REVISION: 8.5      LAST EDIT: 11/22/95       BY: tvo *J094*                */
/* REVISION: 8.5      LAST EDIT: 07/22/96       BY: Mariya Kutwal   *K00C*    */
/* REVISION: 8.5      LAST EDIT: 10/08/96       BY: John Worden     *K00C*    */
/* REVISION: 8.6      LAST MODIFIED: 03/18/97   BY: Verghese Kurien *K07Q*    */
/* REVISION: 8.6      LAST MODIFIED: 05/23/97   BY: Joe Gawel       *K0B1*    */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 09/15/98   BY: *N02Q* Prashanth Narayan  */
/* REVISION: 9.1      LAST MODIFIED: 10/26/99   BY: *N04G* Prashanth Narayan  */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00   BY: *N0KW* Jacolyn Neder      */
/* REVISION: 9.1      LAST MODIFIED: 08/24/00   BY: *N0MZ* Mudit Mehta        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.8.1.7       BY: Katie Hilbert      DATE: 05/25/02  ECO: *P072* */
/* Revision: 1.8.1.10      BY: Jean Miller        DATE: 06/21/02  ECO: *P09H* */
/* $Revision: 1.8.1.11 $   BY: Amit Chaturvedi    DATE: 05/07/03  ECO: *N2F0* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input        parameter ecm_recid as   recid.
define input        parameter prog_name as   character.
define output       parameter mtitle    like mnt_label.
define input-output parameter section   as   integer.

define temp-table doclist
   field t_seqnbr as   integer
   field doc      like mnt_label
   index t_seqdoc is primary
      t_seqnbr ascending.

define shared variable global_passwd      as character.
define shared variable global_user_groups as character format "x(60)"
   label "Groups".

define variable mfc_yn        as   character             no-undo.
define variable d_array       like doc      extent 10    no-undo.
define variable p_array       like mnd_exec extent 10    no-undo.
define variable k             as   integer               no-undo.
define variable ilist         as   character             no-undo.
define variable can_do_menu   as   logical               no-undo.
define variable user_excluded like mfc_logical           no-undo.
define variable group_indx    as   integer               no-undo.
define variable tmp_canrun    as   character             no-undo.

define buffer mnddet for mnd_det.

{ecwndvar.i}  /* SCROLLING WINDOW VARIABLES */

for first ecm_mstr
   fields(ecm_close_date)
   where recid(ecm_mstr) = ecm_recid
   no-lock:
end. /* FOR FIRST ecm_mstr */

if not available ecm_mstr
then do:

   hide frame w1.
   return.
end. /* IF NOT AVAILABLE ecm_mstr */

for each doclist
   exclusive-lock:
   delete doclist.
end. /* FOR EACH doclist */

assign
   ilist   = "ecmtb01.p,ecmtb02.p,ecmtb03.p,ecmtb04.p,ecmtb05.p,ecmtb06.p"
   ilist   = ilist + ",ecmtb07.p,ecmtb08.p"
   ilist   = ilist + ",ecmtb09.p"
   d_array = fill("X",25).

for first pcc_ctrl
   fields(pcc_ecooff_date pcc_formula_ok pcc_initial_date
          pcc_process_ok  pcc_quality_ok pcc_routing_ok
          pcc_struct_ok)
   no-lock:
end. /* FOR FIRST pcc_ctrl */

for each mnddet
   fields(mnd_exec mnd_nbr mnd_select mnd_canrun)
   no-lock
   where mnd_exec begins "ecmtb"
     and mnd_exec matches "ecmtb...p"
   by mnd_nbr
   by mnd_select:
/*GUI*/ if global-beam-me-up then undo, leave.


   {mfsec.i "mnddet"}

   /* ONLY DISPLAY A SINGLY SELECTED FUNCTION */
   if prog_name matches "ecmtb...p"
      and prog_name <> mnd_exec
   then
      can_do_menu = no.

   /* DO NOT DISPLAY ECR/ECN FUNCTIONS ON INQUIRY */
   if prog_name = "ececiq.p"
      and mnd_exec = "ecmtb01.p"
   then
      can_do_menu = no.

   /* ONLY ALLOW FUNCTION AND TRAILER MAINTENANCE UNTIL THE */
   /* CONTROL FILE CONVERSION IS RUN                        */
   if ((available pcc_ctrl
      and pcc_initial_date = ?)
      or not available pcc_ctrl)
      and (mnd_exec <> "ecmtb01.p"
      and mnd_exec <> "ecmtb08.p")
   then
      can_do_menu = no.

   /* ONLY ALLOW TRAILER FUNCTIONS IF THE ECN IS CLOSED */
   if ecm_close_date <> ?
      and mnd_exec <> "ecmtb08.p"
   then
      can_do_menu = no.

   /* ONLY ALLOW ITEM MAINTENANCE IF PS MENU ECOs ARE NOT DISABLED */
   if ((available pcc_ctrl
      and pcc_ecooff_date = ?)
      or not available pcc_ctrl)
      and (mnd_exec <> "ecmtb03.p"
      and  mnd_exec <> "ecmtb08.p")
   then
      can_do_menu = no.

   /* DISPLAY PRODUCT STRUCTURE MENU WHEN pcc_struct_ok = yes,     */
   /* DISPLAY ROUTING MENU WHEN pcc_routing_ok = yes, DISPLAY      */
   /* FORMULA MENU WHEN mfc_ctrl WITH mfc_field = "pcc_formula_ok" */
   /* RECORD IS AVAILALBE AND DISPLAY PROCESS MENU WHEN mfc_ctrl   */
   /* WITH mfc_field = "pcc_process_ok" RECORD IS AVAILABLE        */

   /* ALLOW PRODUCT STRUCTURE ONLY IF THEY HAVE BEEN ENABLED */
   if (mnd_exec = "ecmtb04.p")
      and not pcc_ctrl.pcc_struct_ok
      and can_do_menu
   then
      can_do_menu = no.

   /* ALLOW FORMULA ONLY IF THEY HAVE BEEN ENABLED */
   if mnd_exec = "ecmtb06.p"
      and not pcc_ctrl.pcc_formula_ok
      and can_do_menu
   then
      can_do_menu = no.

   /* ALLOW ROUTINGS ONLY IF THEY HAVE BEEN ENABLED */
   if mnd_exec = "ecmtb05.p"
      and not pcc_ctrl.pcc_routing_ok
      and can_do_menu
   then
      can_do_menu = no.

   /* ALLOW PROCESSES ONLY IF THEY HAVE BEEN ENABLED */
   if mnd_exec = "ecmtb07.p"
      and not pcc_ctrl.pcc_process_ok
      and can_do_menu
   then
      can_do_menu = no.

   /* ALLOW ITEM SPECIFICATIONS ONLY IF THEY HAVE BEEN ENABLED */
   if (mnd_exec = "ecmtb09.p")
      and not pcc_ctrl.pcc_quality_ok
      and can_do_menu
   then do:

      mfc_yn = string(false).

      {mfctrl01.i mfc_ctrl qc_enable mfc_yn false no}

      if mfc_yn = string(false)
      then
         can_do_menu = no.
   end. /* IF quality_ok */

   if can_do_menu
   then do:

      for first mnt_det
         fields(mnt_label mnt_lang mnt_nbr mnt_select)
         where mnt_nbr    = mnd_nbr
           and mnt_select = mnd_select
           and mnt_lang   = global_user_lang
         no-lock:

         assign
            d_array[mnd_select] = mnt_label
            p_array[mnd_select] = mnd_exec.

         create doclist.

         assign
            t_seqnbr = mnd_select
            doc      = d_array[mnd_select].
      end. /* FOR FIRST mnt_det */

   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* IF can_do_menu */
end. /* FOR EACH mnddet */

assign
   section     = 0
   window_row  = 6
   window_down = 10.

repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

   mtitle = "".

   /* REPLACED 4th PARAMETER FROM "/**/"      */

   {ecwindow.i doclist
      "doc no-label"
      doc
      "use-index t_seqdoc"
      "yes"
      getFrameTitle(""SELECT_PCR/PCO_SECTION"",35)
      "no-labels width 67 centered attr-space"
      "1"
      doc}

   if lastkey = keycode("GO")
      or lastkey = keycode("F1")
      or lastkey = 301 or keyfunction(lastkey) = "GO"
      or lastkey = keycode("RETURN")
   then do:

      global_recid = recidarray[i].

      arrayloop:
      do k = 1 to 9:

         if ix1array[i] = d_array[k]
         then do:

            assign
               section = lookup(p_array[k],ilist)
               mtitle  = d_array[k].
            hide frame w1.
            return.
         end. /* IF ix1array[i] = d_array[k] */
      end. /* DO k = 1 to 9 */

   end. /* IF lastkey = keycode("GO") */
   else do:

      assign
         frame-value  = frame_val_save
         global_recid = ?.

      if keyfunction(lastkey)    = "end-error"
         or keyfunction(lastkey) = "endkey"
         or lastkey              = keycode("F4")
      then do:

         hide frame w1.
         return.
      end. /* IF keyfunction(lastkey)    = "end-error" */

      apply lastkey.

   end. /* ELSE DO */

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* REPEAT */

global_recid = ?.
